/**
 * ControladoraPeriodo.java
 */

 /**
 *  AdSec: Administrador de Secundarias
 *  Copyright (C) 2009 Daniela Ramírez Chaves (dannyrch@gmail.com)
 *  Copyright (C) 2009 Leonel Salazar Valverde (leo87sv@gmail.com)
 *
 *  This file is part of AdSec.
 *  AdSec is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  AdSec is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with AdSec.  If not, see <http://www.gnu.org/licenses/>.
 */

package adsec.negocios;

import java.util.Iterator;
import adsec.datos.ControladoraBDPeriodo;
import adsec.entidades.Periodo;
import adsec.entidades.Periodos;


public class ControladoraPeriodo {

    private ControladoraBDPeriodo controladoraBDPeriodo;

    public ControladoraPeriodo(){
        this.controladoraBDPeriodo = new ControladoraBDPeriodo();
    }//fin de constructor

    public Periodo consultarPeriodo(int idMateria, int idPeriodo, int numPeriodo){
        return this.controladoraBDPeriodo.consultarPeriodo(idMateria, idPeriodo, numPeriodo);
    }

    public Periodos consultarPeriodos(int idMateria, int idMateriaCursada){
        return this.controladoraBDPeriodo.consultarPeriodos(idMateria, idMateriaCursada);
    }

    public int insertarPeriodos(Periodos periodos){
        return this.controladoraBDPeriodo.insertarPeriodos(periodos);
    }

    public int modificarPeriodos(Periodos periodos){
        return this.controladoraBDPeriodo.modificarPeriodos(periodos);
    }

    public int eliminarPeriodos(int idMateria, int idMateriaCursada){
        return this.controladoraBDPeriodo.eliminarPeriodos(idMateria, idMateriaCursada);
    }

    public static boolean validarPeriodos(Periodos periodos){
        Iterator<Periodo> iterador = periodos.getIterador();
        double suma = 0;
        while(iterador.hasNext()){
            suma += iterador.next().getPorcentaje();
        }
        return suma == 100.0;
    }

}//fin de ControladoraPeriodo
